<template>
  <HomePanel title="人气推荐" sub-title="人气爆款 不容错过" ref="target">
    <template #default>
      <ul ref="pannel" class="goods-list" v-if="list.length">
        <li v-for="item in list" :key="item">
          <RouterLink to="/">
            <img v-imgLazy="item.picture" alt=""   />
            <p class="name">{{item.title}}</p>
            <p class="desc">{{item.alt}}</p>
          </RouterLink>
        </li>
      </ul>
      <ul ref="pannel" class="goods-list" v-else>
        <li v-for="item in 4" :key="item">
            <XtxSkeleton :width='306' :height="406" />
        </li>
      </ul>
    </template>
  </HomePanel>
</template>

<script>
import { findHomeHot } from '@/api/home'
import HomePanel from './home-panel'
import { useObserver } from '@/compositions'
export default {
  components: { HomePanel },
  setup () {
    const { list, target } = useObserver(findHomeHot)
    // console.log(list)
    return { list, target }
  }
}
</script>

<style scoped lang='less'>
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }
    .desc {
       color: #999;
      font-size: 18px;
    }
  }
}
</style>
